﻿using LD.Host.Sqlguar;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LD.Host
{
    public class DBHelper
    {
        private static object obj = new object();
        private static DBHelper instance;
        private static string _path = AppDomain.CurrentDomain.BaseDirectory;
        public SqlSugarScope Sql { get; private set; }
        private DBHelper()
        {
            Sql = new SqlSugarScope(new ConnectionConfig()
            {
                DbType = DbType.Sqlite,
                ConnectionString = "Data Source=" + _path + "Config\\db",
                IsAutoCloseConnection = true,
            });

            Sql.CodeFirst.InitTables(typeof(TB_ScrewData));
            Sql.CodeFirst.InitTables(typeof(TB_ScrewDetailData));
            Sql.CodeFirst.InitTables(typeof(TB_PressData));

        }
        public static DBHelper Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (obj)
                    {
                        if (instance == null)
                            instance = new DBHelper();
                    }
                }
                return instance;
            }
        }
    }
}
